<template>
  <div>
    <el-table :class="showHead ? 'has-bg' : ''" :data="tableData" style="width: 100%" :show-header="showHead" :border="true">
        <el-table-column align="left" prop="projectName" label="" width="120">
          <template slot-scope="scope">
            <span v-if="scope.row.projectKey && scope.row.projectKey != 'group'" class="cursor-pointer-line padding-left-10" @click="goInfo(scope.row)">{{ scope.row.projectName }}</span>
            <span v-else class="padding-left-10 cursor-pointer-line" @click="goInfo(scope.row)">{{ scope.row.projectName }}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="projectName">
          <template #header>
            <span>总建筑面积·天</span>
            <span v-tooltip="'总建筑面积'" class="icon el-icon-question padding-left-5"></span>
          </template>
          <template slot-scope="scope">
            <span class="cursor-pointer-line" @click="goInfo(scope.row)">{{ scope.row.totalBuildingArea | moneyFilterNoUnit }}</span>
          </template>
        </el-table-column>
        <el-table-column align="center">
          <template #header>
            <span>地毯面积·天</span>
            <span v-tooltip="'地毯面积'" class="icon el-icon-question padding-left-5"></span>
          </template>
          <template slot-scope="scope">
            <span class="cursor-pointer-line" @click="goInfo(scope.row)">{{ scope.row.carpetArea | moneyFilterNoUnit }}</span>
          </template>
        </el-table-column>
        <el-table-column v-if="dialogType == 11" align="center" label="空置面积·天" class-name="head1" key="vacancyArea">
          <template slot-scope="scope">
            <span class="cursor-pointer-line" @click="goInfo(scope.row)">{{ scope.row.vacancyArea | moneyFilterNoUnit }}</span>
          </template>
        </el-table-column>
        <el-table-column v-if="dialogType == 12" align="center" label="在租地毯面积·天" class-name="head1" key="rentedCarpetArea">
          <template slot-scope="scope">
            <span class="cursor-pointer-line" @click="goInfo(scope.row)">{{ scope.row.rentedCarpetArea | moneyFilterNoUnit }}</span>
          </template>
        </el-table-column>
        <el-table-column v-if="dialogType == 12" align="center" :label="`商铺-散铺${typeName}面积·天`" class-name="head2" key="commercialScatteredRentArea">
          <template slot-scope="scope">
            <span class="cursor-pointer-line" @click="goInfo(scope.row)">{{ scope.row.commercialScatteredRentArea | moneyFilterNoUnit }}</span>
          </template>
        </el-table-column>
        <el-table-column v-if="dialogType == 12" align="center" :label="`商铺-主力店${typeName}面积·天`" class-name="head2" key="commercialMainStoreRentArea">
          <template slot-scope="scope">
            <span class="cursor-pointer-line" @click="goInfo(scope.row)">{{ scope.row.commercialMainStoreRentArea | moneyFilterNoUnit }}</span>
          </template>
        </el-table-column>
        <el-table-column v-if="dialogType == 11" align="center" :label="`商铺${typeName}面积·天`" class-name="head2" key="storeRentArea">
          <template slot-scope="scope">
            <span class="cursor-pointer-line" @click="goInfo(scope.row)">{{ scope.row.storeRentArea | moneyFilterNoUnit }}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" :label="`写字楼${typeName}面积·天`" class-name="head2">
          <template slot-scope="scope">
            <span class="cursor-pointer-line" @click="goInfo(scope.row)">{{ scope.row.officeRentArea | moneyFilterNoUnit }}</span>
          </template>
        </el-table-column>
        <el-table-column align="center" :label="`库房${typeName}面积·天`" class-name="head2">
          <template slot-scope="scope">
            <span class="cursor-pointer-line" @click="goInfo(scope.row)">{{ scope.row.warehouseRentArea | moneyFilterNoUnit }}</span>
          </template>
        </el-table-column>
        <el-table-column v-if="dialogType == 12" align="center" width="100" key="usedRate">
          <template #header>
            <span>使用系数·天</span>
            <span v-tooltip="'使用系数'" class="icon el-icon-question padding-left-5"></span>
          </template>
          <template slot-scope="scope">
            <span class="cursor-pointer-line" @click="goInfo(scope.row)">{{ scope.row.usedRate | accMul }}%</span>
          </template>
        </el-table-column>
        <el-table-column v-if="dialogType == 12" align="center" width="100" key="rentalRate">
          <template #header>
            <span>出租率·天</span>
            <span v-tooltip="'出租率'" class="icon el-icon-question padding-left-5"></span>
          </template>
          <template slot-scope="scope">
            <span class="cursor-pointer-line" @click="goInfo(scope.row)">{{ scope.row.rentalRate | accMul }}%</span>
          </template>
        </el-table-column>
        <el-table-column v-if="dialogType == 11" align="center" width="100" key="vacancyRate">
          <template #header>
            <span>空置率·天</span>
            <span v-tooltip="'空置率'" class="icon el-icon-question padding-left-5"></span>
          </template>
          <template slot-scope="scope">
            <span class="cursor-pointer-line" @click="goInfo(scope.row)">{{ scope.row.vacancyRate | accMul }}%</span>
          </template>
        </el-table-column>
      </el-table>
  </div>
</template>
<script>
  import dayjs from 'dayjs';

  export default {
    props: {
      selectTime: {
        type: Number,
        default: 0,
      },
      dialogType: {
        type: Number,
        default: 1,
      },
      showHead: {
        type: Boolean,
        default: true,
      },
      tableData: {
        type: Array,
        default: () => {
          return [];
        },
      }
    },

    computed: {
      fiscalYear() {
        return dayjs(this.selectTime).format('YYYY');
      },
      fiscalMonth() {
        let date = dayjs(this.selectTime).format('YYYY-MM-DD');
        let month = date.split('-')[1];
        return Number(month);
      },
      fiscalDay() {
        let day = new Date(new Date(this.fiscalYear, this.fiscalMonth).setDate(0)).getDate();
        return day
      },
      title() {
        return this.dialogType == 11 ? "空置业态面积占比情况" : "已租业态面积占比情况"
      },
      typeName() {
        return this.dialogType == 11 ? "空置" : "在租"
      }
    },

    data() {
      return {
       
      };
    },

    methods: {
      goInfo(row, type) {
        let pathName = '';
        let planName = '';
        let planProjectName = '';
        if (row.projectKey == "group") {
          pathName = 'groupmonth-all-plan';
          planName = '集团月报'; //集团月保
          planProjectName = "集团"
        } else {
          pathName = 'execute-all-plan';
          planName = '项目月报'; ////项目月保
          planProjectName = row.projectName
        }

        let queryData = {
          headerName: planName,
          year: this.fiscalYear || '',
          month: this.fiscalMonth,
          planProjectName:planProjectName
        };

        if (row.projectKey && row.projectKey != "group") {
          queryData.projectKey = row.projectKey
        }

        let pathUrl = {
          name: pathName,
          query: queryData,
        };

        let { href } = this.$router.resolve(pathUrl);
        window.open(href);
      },
    },
  };
</script>

<style lang="scss" scoped>
  ::v-deep .el-table {
    .el-table__header-wrapper {
      .head1 {
        background: rgba(247, 145, 0, 0.25) !important;
      }
      .head2 {
        background: rgba(247, 145, 0, 0.1) !important;
      }
    }
    th .cell{
      font-size: 14px;
      padding: 0 3px;
    }
  }

  ::v-deep .has-bg{
    .el-table__body-wrapper{
        .el-table__row{
            background: rgba(51,132,254,0.2);
        }
    }
  }
</style>
